/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author nicolas
 */
public class Direction {
    
    public final static Direction NORD = new Direction("Nord",0,1,0);
    public final static Direction EST = new Direction("Est",1,0,1);
    public final static Direction SUD = new Direction("Sud",0,-1,2);
    public final static Direction OUEST = new Direction("Ouest",-1,0,3);
    private int dx;
    private int dy;
    private int valeur;
    private String label;
    
    private Direction(String label, int dx, int dy, int valeur){
        this.label=label;
        this.dx=dx;
        this.dy=dy;
        this.valeur=valeur;
    }
    
    public String getLabel(){
        return this.label;
    }
    
    public final static Direction[] getDirections(){
        return new Direction[]{Direction.NORD,Direction.EST,Direction.SUD,Direction.OUEST};
    }
    
    public void rotate(int nombre_quarts_de_tour){
        Direction[] directions = Direction.getDirections();
        int nouvelle_valeur = (this.valeur - nombre_quarts_de_tour);
        if(nouvelle_valeur<0) nouvelle_valeur +=4;
        Direction nouvelle_direction = directions[nouvelle_valeur%4];
        this.label = nouvelle_direction.label;
        this.dx = nouvelle_direction.dx;
        this.dy = nouvelle_direction.dy;
        this.valeur = nouvelle_direction.valeur;
    }
    
    public int dx(){
        return this.dx;
    }
    
    public int dy(){
        return this.dy;
    }    
}
